import pygame,math,sys,random

class Dinohealth(pygame.sprite.Sprite):
    def __init__(self, position):
        pygame.sprite.Sprite.__init__(self, self.containers)

        self.surfaces = []
        self.surfaces += [pygame.image.load("rsc/Health/healthbar5.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar10.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar15.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar15.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar20.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar25.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar30.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar35.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar40.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar45.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar50.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar55.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar60.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar65.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar70.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar75.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar80.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar85.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar90.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar95.png")]
        self.surfaces += [pygame.image.load("rsc/Health/healthbar100.png")]
        self.maxFrame = len(self.surfaces)-1
#        self.surface = pygame.transform.scale(self.faces,(100,25))
        self.frame = self.maxFrame
        self.image = self.surfaces[self.frame]
        self.rect = self.image.get_rect()
        self.rect.center = position
        if pygame.mixer:
            self.healthSound = pygame.mixer.Sound("health.wav")
        
       
    def  __str__(self):
        return "I'm a Health Bar " + str(self.rect.center) + str(self.speed) + str(self.living);
        pass
     
    def health_bar(self):
        pass
            
    def update(*args):
        self = args[0]
        life = args[6]
        maxLife = args[7]
        percentLife = float(self.dinosaur.health)/float(self.dinosaur.maxHealth)
        if percentLife > .100:
            self.frame = 20
        elif percentLife > .95:
            self.frame = 19
        elif percentLife > .90:
            self.frame = 18
        elif percentLife > .85:
            self.frame = 17
        elif percentLife > .80:
            self.frame = 16
        elif percentLife > .75:
            self.frame = 15
        elif percentLife > .70:
            self.frame = 14
        elif percentLife > .65:
            self.frame = 13
        elif percentLife > .60:
            self.frame = 12
        elif percentLife > .55:
            self.frame = 11
        elif percentLife > .50:
            self.frame = 10
        elif percentLife > .45:
            self.frame = 9
        elif percentLife > .40:
            self.frame = 8
        elif percentLife > .35:
            self.frame = 7
        elif percentLife > .30:
            self.frame = 6 
        elif percentLife > .25:
            self.frame = 5
        elif percentLife > .20:
            self.frame = 4
        elif percentLife > .15:
            self.frame = 3
        elif percentLife > .10:
            self.frame = 2
        elif percentLife > .5:
            self.frame = 1
        elif percentLife > .0:
            self.living = False
            #print percentLife
  
            #self.living = False
        self.image = self.surfaces[self.frame]